#include <iostream>
#include <memory>
#include <thread>
#include <chrono>
#include <future>

int Add(int num1,int num2)
{
    std::cout << "Add 运算" << std::endl;
    return num1 + num2;
}


int main()
{
    auto task = std::make_shared<std::packaged_task<int(int,int)>>(Add);

    std::future<int> res = task->get_future();

    std::thread thr([&task]{
        (*task)(11,22);
    });
    std::this_thread::sleep_for(std::chrono::seconds(2));
    std::cout << "------------\n";
    
    std::cout << res.get() << std::endl;
    
    thr.join();
    return 0;
}